<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 首页接口
 */
class Room extends Api
{
  protected $noNeedLogin = ['*'];
  protected $noNeedRight = ['*'];

  /**
   * 首页
   *
   */
  public function index()
  {
    $request = $this->request;
    $query = \app\admin\model\Room::whereIn("status",["未使用","清洁中"]);
    if ($location = $request->post('location')){
      $query = $query->where('location','like', "%$location%");
    }
    if ($type = $request->post('type')){
      $query = $query->where('type', $type);
    }
    if ($people = $request->post('people')){
      $query = $query->where('people','ELT', $people);
    }
    if ($priceStart = $request->post('price_start')){
      $query = $query->where('price','ELT', $priceStart);
    }
    if ($priceEnd =  $request->post('price_end')){
      $query = $query->where('price','EGT', $priceEnd);
    }

        $data =   $query->select();
    $this->success('请求成功',$data);
  }
}
